package com.cskaoyan.javase.oop1._7game._1pvz;

/**
 * 僵尸类
 *
 * @since 11:39
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Zombie {
    String name;
    int hp;
    int damage;
    int speed;

    // 持有植物对象引用,方便交互
    Plant zombieP;

    // 构造器
    public Zombie(String name, int hp, int damage, int speed) {
        this.name = name;
        this.hp = hp;
        this.damage = damage;
        this.speed = speed;
    }


    /*
        僵尸的行为
        也需要和植物交互
        共同完成
        为了更好的实现对象间的交互
        常见的做法是
        将交互对象的引用作为自身成员变量持有
     */

    // 向植物移动
    public void move() {
        System.out.println(name + "正在以" + speed + "的速度,向" + zombieP.name + "移动!");
    }

    // 僵尸要攻击植物
    public void attack() {
        System.out.println(name + "正在攻击" + zombieP.name);
    }

    public void beAttacked() {
        System.out.println(name + "正在被" + zombieP.name + "攻击,我还剩下" + (hp - zombieP.damage) + "点血量!");
    }

    public void eat() {
        System.out.println("僵尸吃掉了你的脑子,真香!");
    }
}
